/*
 * @Author: sky 1575951471@qq.com
 * @Date: 2024-06-02 21:09:05
 * @LastEditors: sky 1575951471@qq.com
 * @LastEditTime: 2024-12-03 22:10:13
 * @FilePath: \sky-esp32-Base\components\BSP\SPI\spi.h
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#ifndef __SPI_H
#define __SPI_H

#include <string.h>
#include "esp_log.h"
#include "driver/spi_master.h"
#include "driver/gpio.h"
#include "lcd.h"


/* 引脚定义 */
#define SPI_MOSI_GPIO_PIN   GPIO_NUM_11         /* SPI2_MOSI */
#define SPI_CLK_GPIO_PIN    GPIO_NUM_12         /* SPI2_CLK */
#define SPI_MISO_GPIO_PIN   GPIO_NUM_13         /* SPI2_MISO */
#define LCD_NUM_CS          GPIO_NUM_21         /*SPI2_CS */

extern spi_device_handle_t sky_lcd_handle;                                     //SPI lcd 句柄

/* 函数声明 */
void spi2_init(void);                                                               /* 初始化SPI2 */
void spi2_write_cmd(spi_device_handle_t handle, uint8_t cmd);                       /* SPI发送命令 */
void spi2_write_data(spi_device_handle_t handle, const uint8_t *data, int len);     /* SPI发送数据 */
uint8_t spi2_transfer_byte(spi_device_handle_t handle, uint8_t byte);               /* SPI处理数据 */
uint32_t lcd_get_id(spi_device_handle_t handle);
#endif